package com.woniu;

import com.alibaba.druid.pool.DruidDataSource;

import io.seata.rm.datasource.DataSourceProxy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
//import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: 马宇航
 * @Description: 订单启动类
 * @DateTime: 22/12/06/0006 10:38
 * @Component: 成都蜗牛学苑
 **/
@SpringBootApplication
//@EnableEurekaClient
@EnableFeignClients //开启OpenFeign
@EnableHystrix //开启Hystrix自动配置
public class OrderApp {
    public static void main(String[] args) {
        SpringApplication.run(OrderApp.class,args);
    }
    @Bean
    @LoadBalanced //用的就是ribbon中的负载均衡策略：默认用的轮询
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
    @Primary
    @Bean
    @ConfigurationProperties(prefix = "spring.datasource")
    public DruidDataSource druidDataSource(){
        return new DruidDataSource();
    }
    @Bean
    public DataSourceProxy dataSource(DruidDataSource dataSource){
        return new DataSourceProxy(dataSource);
    }
}